package com.frxuexi.lib_base.utils

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.SPUtils

class MyRecyclerView:RecyclerView {
    private var intercept = true //默认拦截

    fun setIntercept(intercept: Boolean) {
        this.intercept = intercept
    }
    constructor(context: Context) : super(context)
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

//    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
//        if(SPUtils.getInstance().getBoolean("isShow")){
//            return false
//        }
//        return super.onInterceptTouchEvent(ev)
//    }

    override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
        return if (intercept) { //true  拦截
            super.onInterceptTouchEvent(e)
        } else { //false 不拦截
            false
        }
    }
}